package com.woniuxy.his.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.his.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserMapper extends BaseMapper<User> {

    @Insert("insert into his_user values (null,#{username},#{password},default,default)")
    Integer addUser(User user);

    @Select("select role_name from his_role where role_id in (select role_id from his_user_role where user_id=#{userId})")
    public List<String> findRole(int userId);

    @Select("select permission_name from his_permission where permission_id in(select permission_id from his_role_permission where role_id in(select role_id from his_user_role where user_id=#{userId})) ")
    public List<String> findPermissions(int userId);
}
